USE [xRepair]
GO

IF OBJECT_ID('[dbo].[AddNewCity]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[AddNewCity]
END
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[AddNewCity]
		 @StateID				INT
		,@CityName				NVARCHAR(255)
		,@CreatedAt				DATETIME = NULL
		,@CreatedBy				NVARCHAR(50) = NULL		
		,@NewIdentity			INT = NULL OUTPUT
AS
BEGIN

	SET NOCOUNT ON;
	
	INSERT INTO [dbo].[Cities]
           ([StateID]
		   ,[CityName]
           ,[IsActive]
           ,[CreatedAt]
           ,[CreatedBy])
     VALUES
           (@StateID
		   ,@CityName
           ,1
           ,@CreatedAt
           ,@CreatedBy)

	SELECT @NewIdentity = @@IDENTITY

END

GO


